package cc.eddic.practice.spring.domain;

import cc.eddic.practice.spring.jpa.BaseEntity;
import lombok.*;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "t_option")
@Builder
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class Option extends BaseEntity {

    private char choice;
    @Column(length = 50)
    private String answer;
    private boolean isCorrect;

    @ToString.Exclude
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "question_id")
    private Question question;


    public Option(char choice, String answer, boolean isCorrect) {
        this.choice = choice;
        this.answer = answer;
        this.isCorrect = isCorrect;
    }
}
